package com.mszlu.msauth.admin.controller;

import com.mszlu.msauth.admin.JWTUtil;
import com.mszlu.msauth.response.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/auth")public class AuthController {
    @PostMapping("/login")
    public Result<LoginResult> login(@RequestBody LoginDTO loginDTO) {
        // 生成token
         Map<String,String> map = new HashMap<>(1);
         map.put("username",loginDTO.getUsername());
         String accessToken = JWTUtil.getToken(map,"123456");
         LoginResult loginResult = LoginResult.builder()                .tokenType("Bearer")                .accessToken(accessToken)                .build();
         return Result.success(loginResult);
         }
}